package com.example.my_demo.service.impl;

import com.example.my_demo.entity.User;
import com.example.my_demo.mapper.UserMapper;
import com.example.my_demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service

public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }

    @Override
    public int addUser(User user) {
      return userMapper.insertUser(user.getUsername(),user.getPassword(),user.getAge(),user.getSex());

    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user.getUsername(),user.getPassword(),user.getAge(),user.getSex(),user.getId());
    }

    @Override
    public int deleteUser(int id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public List<User> getAllUser() {
        return userMapper.getAllUser();
    }
}
